package com.sh.data.engine.domain.datadev.offline.model.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
//@ApiModel
public class OfflineDevDataQualityDetailDomain {

    /**
     * 表id
     */
//    @ApiModelProperty(value = "表id", required = true)
    private Long tblId;

    /**
     * 字段名，多个字段名用逗号隔开
     */
//    @ApiModelProperty(value = "字段名，多个用逗号隔开", required = true)
    private String fieldNames;

    /**
     * 字段类型，多个字段名用逗号隔开
     */
//    @ApiModelProperty(value = "字段类型，多个用逗号隔开", required = true)
    private String fieldTypes;

    //    @ApiModelProperty(value = "分区表达式")
    private String partitionExpression;

    //    @ApiModelProperty(value = "规则类型 0-字段级规则 1-表级规则 ，模版规则必填", allowableValues = "0,1")
    private Integer ruleType;

    /**
     * 规则模版id
     */
//    @ApiModelProperty(value = "规则模版id，模版规则必填")
    private Long templateId;

    /**
     * 规则判断条件，json格式
     */
//    @ApiModelProperty(value = "规则判断条件，json格式，如：[{'key':'max','value':20},{'key':'min','value':10}]")
    private String ruleCondition;

    /**
     * 0-大于 1-大于等于 2-等于 3-小于 4-小于等于 5-不等于 6-属于 7-不属于
     */
//    @ApiModelProperty(value = "比较方式，0-大于 1-大于等于 2-等于 3-小于 4-小于等于 5-不等于 6-属于 7-不属于")
    private String ruleCompareType;

    //    @ApiModelProperty(value = "比较方式，0-大于 1-大于等于 2-等于 3-小于 4-小于等于 5-不等于 6-属于 7-不属于")
    private String ruleCompareTypeName;

    /**
     * 期望值
     */
//    @ApiModelProperty(value = "期望值")
    private String ruleExpectValue;

    /**
     * 是否是自定义规则 0-否 1-是
     */
//    @ApiModelProperty(value = "是否是自定义规则 0-否 1-是", allowableValues = "0,1", required = true)
    private Integer ruleDiy;

    /**
     * 描述
     */
//    @ApiModelProperty(value = "描述")
    private String remark;

    /**
     * 规则名称
     */
    private String ruleName;

    /**
     * 表名
     */
    // @NotBlank(message = "表名不能为空")
    private String tblName;

    /**
     * 规则模版名字 为了省去一步表连接存的时候就存进去
     */
    private String templateName;

    /**
     * 分类 0-完整性 1-准确性 2-唯一性 3-有效性
     */
    private Integer templateCategory;

    //    @ApiModelProperty(value = "规则条件")
    private List<RuleCondition> ruleConditions;

    //    @ApiModelProperty(value = "比较方式集合")
    private List<CompareType> compareTypes;

    //    @ApiModelProperty(value = "期望值")
    private ExpectValue expectValue;

    @Data
//    @ApiModel
    public static class RuleCondition {

        //    @ApiModelProperty(value = "字段名")
        private String name;

        //    @ApiModelProperty(value = "输入项，可能有多个")
        private List<RuleConditionItem> items;
    }

    @Data
    public static class RuleConditionItem {

        //    @ApiModelProperty(value = "字段key")
        private String key;

        //    @ApiModelProperty(value = "说明")
        private String placeholder;

        //    @ApiModelProperty(value = "输入框类型", allowableValues = "text,number,date")
        private String dataType;
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
//    @ApiModel
    public static class CompareType {
        //    @ApiModelProperty(value = "比较方式值")
        private Integer compareType;

        //    @ApiModelProperty(value = "比较方式名")
        private String desc;
    }

    @Data
    public static class ExpectValue {

        //    @ApiModelProperty(value = "输入框类型", allowableValues = "text,number,date,datetime")
        private String dataType;
    }

    //    @ApiModelProperty(value = "模版规则过滤条件")
    private String templateFilter;

    //    @ApiModelProperty(value = "自定义规则的sql")
    private String diySql;
}
